package github.pop.ares.block;

import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;

public class ObsidianCounterTileEntity extends TileEntity {

    private int counter = 0;
    public ObsidianCounterTileEntity() {
        super(TileEntityTypeRegistry.obsidianCounterTileEntity.get());
    }

    public int increase() {
        counter++;
        setChanged();// some update
        return counter;
    }

    @Override
    public void load(BlockState state, CompoundNBT compound) {
        // read
        counter = compound.getInt("counter");
        super.load(state, compound);
    }

    @Override
    public CompoundNBT save(CompoundNBT compound) {
        // write
        compound.putInt("counter",counter);
        return super.save(compound);
    }
}
